#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
typedef struct verb
{
	int x1;
	int y1;
	int z1;
	int x2;
	int y2;
	int z2;
}v;
int main()
{
	int Verb[21][21][21] = { 0 };;
	int w = 0;
	int x = 0;
	int h = 0;
	scanf("%d%d%d", &w, &x, &h);

	int i = 0;
	int j = 0;
	int n = 0;
	for (i = 0; i < w; i++)
	{
		for (j = 0; j < x; j++)
		{
			for (n = 0; n < h; n++)
			{
				Verb[i][j][n] = 1;
			}
		}
	}

	int p = 0;
	scanf("%d", &p);
	v* vp = (v*)malloc(p * sizeof(v));
	for (i = 0; i < p; i++)
	{
		scanf("%d%d%d%d%d%d", &vp[i].x1, &vp[i].y1, &vp[i].z1, &vp[i].x2, &vp[i].y2, &vp[i].z2);
	}
	int i2 = 0;
	for (i2 = 0; i2 < p; i2++)
	{
		for (i = vp[i2].x1 - 1; i <= vp[i2].x2 - 1; i++)
		{
			for (j = vp[i2].y1 - 1; j <= vp[i2].y2 - 1; j++)
			{
				for (n = vp[i2].z1 - 1; n <= vp[i2].z2 - 1; n++)
				{
					Verb[i][j][n] = 0;
				}
			}
		}
	}
	int count = 0;
	for (i = 0; i < w; i++)
	{
		for (j = 0; j < x; j++)
		{
			for (n = 0; n < h; n++)
			{
				count += Verb[i][j][n];
			}
		}
	}
	printf("%d", count);
	return 0;
}
